#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
const int maxn = 1e4+100;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    map<int, int> C;
    map<int, int> Hl, Hr;
    int N, D; cin >> N >> D;
    for (int i = 0; i < N; ++i) {
        int p, h; cin >> p >> h;
        C[p] = h;
    }
    deque<int> H;
    for(auto &c:C){
        int p = c.first, h = c.second;

        while (!H.empty() && H.front() < p-D) H.pop_front();
        while (!H.empty() && C[H.back()] <= h) H.pop_back();
        H.push_back(p);

        Hr[p] = C[H.front()];
    }
    H.clear();
    for (auto it = C.rbegin(); it!=C.rend(); ++it){
        int p = it->first, h = it->second;

        while (!H.empty() && H.front() > p+D) H.pop_front();
        while (!H.empty() && C[H.back()] <= h) H.pop_back();
        H.push_back(p);

        Hl[p] = C[H.front()];
    }
    int ans = 0;
    for(auto &c:C){
        int p = c.first, h = c.second;
        if(Hl[p] >= 2*h && Hr[p] >= 2*h) ++ans;
    }
    cout << ans;
    return 0;
}
